import pandas as pd

def signal(*args):
    df = args[0]
    n = args[1]
    diff_num = args[2]
    factor_name = args[3]

    # 开低高收
    olch = (df['open'] - df['low']) + (df['high'] - df['low']) + (df['high'] - df['close'])
    # 开高低收
    ohcl = (df['high'] - df['open']) + (df['high'] - df['low']) + (df['close'] - df['low'])
    # 盘中最短路径
    price_min_path = pd.concat([olch, ohcl], axis=1).min(axis=1)
    tr = price_min_path + abs(df['open'] - df['close'].shift(1))

    main_factors = (df['quote_volume'] / tr * df['open']).rolling(n, min_periods=3).std()

    df[factor_name] = main_factors

    if diff_num > 0:
        raise NotImplementedError('暂不支持diff_num，请在因子内添加add_diff相关逻辑')
    else:
        return df
